package com.hsgene.sample.exception;

import com.hsgene.common.util.exception.ErrorCode;

/**
 * @desc:
 * @author: fuxiang
 * @date: 2018/8/14 17:01
 */
public enum SampleErrorCode implements ErrorCode {

    OPERATION_FAILED(30001, "operation_failed", "操作失败"),

    PRIMARY_KEY_CANNOT_BE_EMPTY(30002, "primary_key_cannot_be_empty", "样本主键不能为空"),

    OBJECT_IS_EMPTY(30003, "object_is_empty", "对象为空"),

    ALREADY_USED(30009, "already_used", "当前样本已被使用，不可删除"),

    NUMBER_CANNOT_BE_EMPTY(30010, "number_cannot_be_empty", "编号不能为空"),
    TYPECAN_NOT_BE_EMPTY(30011,"typecan_not_be_empty","type不能为空");
    private final int code;

    private final String message;

    private final String description;

    SampleErrorCode(int code, String message, String description) {
        this.code = code;
        this.message = message;
        this.description = description;
    }

    public static SampleErrorCode getEnum(int code) {
        for (SampleErrorCode sampleErrorCode : values()) {
            if (sampleErrorCode.code == code) {
                return sampleErrorCode;
            }
        }
        throw new IllegalArgumentException("No element matches " + code);
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public String getDescription() {
        return description;
    }
}
